package test

import grails.test.*

/**
 * Created with IntelliJ IDEA.
 * User: rgrinev
 * Date: 10.02.14
 * Time: 11:02
 * To change this template use File | Settings | File Templates.
 */
class ApplicationIntegrationTests extends GrailsUnitTestCase{

    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testAddDepartment() {
        def controller = new ApplicationController()

        Organization org = new Organization(id: 1, name: 'testorg')
        org.save(flush: true)
        controller.params.orgid = org.id
        controller.params.name = 'INTEGRATION TEST'
        controller.create()
        assertNotNull(Department.findWhere(name: 'INTEGRATION TEST'))

        controller.params.name = 'INTEGRATION UPDATE'
        controller.update()
        assertEquals(Department.findWhere(name: 'INTEGRATION UPDATE').name, 'INTEGRATION UPDATE')

        controller.delete()
        assertNull(Department.findWhere(name: 'INTEGRATION UPDATE'))

    }

}
